<?php

require('lib/SimpleSHM.php');

print 'start<br>';

$shmno = 1623;

$results = array(
	'user' => 'John',
	'password' => '123456',
	'posts' => array('My name is John', 'My name is not John')
);
$results['m13713393257'] = '123456';
$data = json_encode($results);

$shmid = @shmop_open($shmno, 'a', 0, 0);
echo $shmid;
$read=false;
if($shmid && $read)
{	
	$rsize = shmop_size($shmid);
	echo 'read......'.$shmid.'-----'.$rsize;
	$storedarray = (array)json_decode(shmop_read($shmid, 0, $rsize));
	echo 'end and print ....';
	print_r($storedarray);
	echo isset($storedarray['m13713393257']);
}
else
{
	$wsize = mb_strlen($data, 'UTF-8');
	shmop_delete($shmid);
    shmop_close($shmid);
	$shmid = shmop_open($shmno, 'c', 0755, $wsize);
	echo 'open and write'.$shmid;
	shmop_write($shmid, $data, 0);
}

/*
$memory = new SimpleSHM;
$memory->write($data);
$storedarray = json_decode($memory->read());
print_r($storedarray);
*/
